
import axios from "axios";
//引入进度条（必须引入nprogress.css的样式）
import Nprogress from 'nprogress'
import 'nprogress/nprogress.css'
//创建axios实例对象
const instance = axios.create({
    baseURL:`http://api.tianapi.com`, //接口地址仅供参考
    timeout: 5000
})

//axios请求拦截器
instance.interceptors.request.use((config) =>{
    Nprogress.start()
    return config;
},error => {
    Nprogress.done()
    return Promise.reject(error)
})

//axios响应拦截器
instance.interceptors.response.use((res) =>{
    Nprogress.done()
    console.log(res.data)
    return res.data;
},error => {
    Nprogress.done()
    return Promise.reject(error)
})

export default instance

